package gui;

import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JPanel;

public class GamePanel extends JPanel{
	
	private static final long serialVersionUID = 1L;
	private String runGamePanelName = "RunGamePanel"; 
	
	public GamePanel(){
		super(new GridBagLayout()); 
	}
	
	public void setGameSettingsPanel(JPanel settingsPanel){
		GridBagConstraints constraints = new GridBagConstraints();
		constraints.gridx = 1; 
		constraints.gridy = 0; 
		add(settingsPanel, constraints);
	}
	
	public void setRunGamePanel(JPanel runGamePanel){
		removeRunningGamePanel();
		runGamePanel.setName(runGamePanelName); 
		GridBagConstraints constraints = new GridBagConstraints();
		constraints.gridx = 1; 
		constraints.gridy = 1; 
		constraints.anchor = GridBagConstraints.CENTER; 
		add(runGamePanel, constraints);
	}
	
	private void removeRunningGamePanel(){
		for (Component comp : getComponents()) {
			if (runGamePanelName.equals(comp.getName())){
				remove(comp); 
				break; 
			}
		}
	}
	
	public void setPhenotypeListPanel(JPanel listPanel){
		GridBagConstraints constraints = new GridBagConstraints();
		constraints.gridx = 0; 
		constraints.gridy = 1;
		constraints.gridheight = 2; 
		add(listPanel, constraints);
	}
	
}
